﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceCS.LinuxFilePermission.Core
{
    public class FilePermissionSetter
    {
        private FilePermission _permission;
        public FilePermissionSetter(FilePermission permission)
        {
            _permission = permission;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="permission"></param>
        /// <returns></returns>
        public FilePermissionSetter Add(FilePermission permission)
        {
            _permission |= permission;
            return this;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="permission"></param>
        /// <returns></returns>
        public FilePermissionSetter Remove(FilePermission permission)
        {
            _permission &= ~permission;
            return this;
        }


        public bool HasPerm(FilePermission permission)
        {
            return _permission.HasFlag(permission);
        }

        public FilePermission GetPermission()
        {
            return _permission;
        }
    }
}
